package com.hkts.naturalgasauthentication.utils.sms;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

/**
 * @ClassNameNamedPatameter
 * @Description
 * @Author yck
 * @Date2021-08-03 16:51
 * @Version V1.0
 **/
public class NamedPatameter {
    String key;


    String value;


    /**
     * 返回 key
     *
     * @return key值
     */
    public String getKey() {
        return key;
    }


    /**
     * 对key进行赋值
     *
     * @param key key值
     */
    public void setKey(String key) {
        this.key = key;
    }


    /**
     * 返回 value
     *
     * @return value值
     */
    public String getValue() {
        return value;
    }


    /**
     * 对value进行赋值
     *
     * @param value value值
     */
    public void setValue(String value) {
        this.value = value;
    }

    static void trustAllHttpsCertificates() throws Exception {

        TrustManager[] trustAllCerts = new TrustManager[] {
                new X509TrustManager() {
                    @Override
                    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                        return;
                    }


                    @Override
                    public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                        return;
                    }


                    @Override
                    public X509Certificate[] getAcceptedIssuers() {
                        return null;
                    }
                }
        };
        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, null);
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    }
}
